/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fanta.framework.persistence;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author alessandro
 */
@Entity
@Table(name = "utente")
@NamedQueries({
    @NamedQuery(name = "Utente.findAll", query = "SELECT u FROM Utente u"),
    @NamedQuery(name = "Utente.findById", query = "SELECT u FROM Utente u WHERE u.id = :id"),
    @NamedQuery(name = "Utente.findByUser", query = "SELECT u FROM Utente u WHERE u.user = :user"),
    @NamedQuery(name = "Utente.findByPasswordcifrata", query = "SELECT u FROM Utente u WHERE u.passwordcifrata = :passwordcifrata"),
    @NamedQuery(name = "Utente.findByAdmin", query = "SELECT u FROM Utente u WHERE u.admin = :admin")})
public class Utente implements Serializable {
    private static final long serialVersionUID = 1L;
    @Basic(optional = false)
    @Column(name = "id")
    private int id;
    @Id
    @Basic(optional = false)
    @Column(name = "user")
    private String user;
    @Basic(optional = false)
    @Column(name = "passwordcifrata")
    private String passwordcifrata;
    @Basic(optional = false)
    @Column(name = "admin")
    private boolean admin;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
    private Collection<Team> teamCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
    private Collection<Lega> legaCollection;

    public Utente() {
    }

    public Utente(String user) {
        this.user = user;
    }

    public Utente(String user, int id, String passwordcifrata, boolean admin) {
        this.user = user;
        this.id = id;
        this.passwordcifrata = passwordcifrata;
        this.admin = admin;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public String getPasswordcifrata() {
        return passwordcifrata;
    }

    public void setPasswordcifrata(String passwordcifrata) {
        this.passwordcifrata = passwordcifrata;
    }

    public boolean getAdmin() {
        return admin;
    }

    public void setAdmin(boolean admin) {
        this.admin = admin;
    }

    public Collection<Team> getTeamCollection() {
        return teamCollection;
    }

    public void setTeamCollection(Collection<Team> teamCollection) {
        this.teamCollection = teamCollection;
    }

    public Collection<Lega> getLegaCollection() {
        return legaCollection;
    }

    public void setLegaCollection(Collection<Lega> legaCollection) {
        this.legaCollection = legaCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (user != null ? user.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Utente)) {
            return false;
        }
        Utente other = (Utente) object;
        if ((this.user == null && other.user != null) || (this.user != null && !this.user.equals(other.user))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fanta.framework.persistence.Utente[user=" + user + "]";
    }

}
